package org.jeecg.modules.demo.stockmanage.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.jeecg.modules.demo.stockmanage.entity.*;

import java.util.List;
import java.util.Map;

/**
 * @Description: 股东管理
 * @Author: jeecg-boot
 * @Date: 2022-01-14
 * @Version: V1.0
 */
public interface StockManageMapper extends BaseMapper<StockManage> {
    /**
     * 查询股东列表
     *
     * @param stockName
     * @return
     */
    IPage<StockManage> searchStockList(Page page, @Param("stockName") String stockName, @Param("storeId") String storeId);

    /**
     * 查询股东统计数据
     *
     * @param storeId
     * @param stockId
     * @return
     */
    StockDataCount getStockDataCount(@Param("storeId") String storeId, @Param("stockId") String stockId);

    /**
     * 根据会员id查询股东信息
     *
     * @param memberId
     * @return
     */
    StockManage getByMemberId(@Param("memberId") String memberId);

    /**
     * 查询股东分红统计
     *
     * @param storeId
     * @param stockId
     * @return
     */
    StockDividendCount getStockDividendCount(@Param("storeId") String storeId, @Param("stockId") String stockId);

    /**
     * 查询股东股本统计
     *
     * @param storeId
     * @param memberId
     * @return
     */
    StockEquityCount getStockEquityCount(@Param("storeId") String storeId, @Param("memberId") String memberId);

    /**
     * 设置股东管家
     *
     * @param id
     * @param shareholdersHousekeeperId
     * @return
     */
    void updateHouseKeeper(@Param("id") String id, @Param("shareholdersHousekeeperId") String shareholdersHousekeeperId,
                           @Param("shareholdersRatio") String shareholdersRatio, @Param("memberRatio") String memberRatio);

    /**
     * @param shareholdersHousekeeperId
     */
    void deleteHouseKeeper(@Param("shareholdersHousekeeperId") String shareholdersHousekeeperId);

    /**
     * @param stockId
     */
    void deleteHouseKeeperByStockId(@Param("stockId") String stockId);

    void updateCanWithdrawal(@Param("stockId") String stockId, @Param("totalDividend") Double totalDividend, @Param("withdrawalAmount") Double withdrawalAmount);

    void refreshMemberQty();

    List<StockManage> getNoHousekeeperStockList(@Param("storeId") String storeId);

    void cleanShareholdersHousekeeper(@Param("id") String id);

    IPage<Map<String, Object>> listStockDividendRecord(Page<Map<String, Object>> page, @Param("storeId") String storeId, @Param("stockId") String stockId, @Param("createTime") String createTime);

    Double getStockDividendSum(@Param("storeId") String storeId, @Param("memberId") String memberId, @Param("stockId") String stockId);

    IPage<Map<String, Object>> listStockBalanceRecord(Page<Map<String, Object>> page, @Param("storeId") String storeId, @Param("stockId") String stockId, @Param("createTime") String createTime, @Param("name") String name);

    IPage<Map<String, Object>> listStockWidthRecord(Page<Map<String, Object>> page, @Param("storeId") String storeId, @Param("stockId") String stockId, @Param("createTime") String createTime);

    List<StockDividend> getListStockDividend(@Param("stockId") String stockId);

}
